import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[] a = s.split(";");
        System.out.println(isIsomorphic(a[0], a[1]));
    }

    public static boolean isIsomorphic(String s, String t) {
        if(s.length() != t.length()) return false;
        if(s.length() == 0) return true;
        HashMap<Character, Character> map = new HashMap<Character, Character>();
        for(int i = 0; i < s.length(); i++) {
            char sChar = s.charAt(i);
            char tChar = t.charAt(i);
            if(map.containsKey(sChar)) {
                if(!map.get(sChar).equals(tChar))
                    return false;
            }
            else {
                if(map.containsValue(tChar))
                    return false;
                map.put(sChar, tChar);
            }
        }
        return true;
    }
    public static int maxSubArray(String[] a) {
        int length = a.length;
        if(length <= 0) {
            return 0;
        }
        int sum = 0;
        int max = Integer.MIN_VALUE;
        for(String num:a) {
            if(sum <= 0)
                sum = Integer.parseInt(num);
            else sum += Integer.parseInt(num);
            if(sum > max)
                max = sum;
        }
        return max;
    }
}